﻿using Tao.OpenGl;

namespace GameStructure.Types
{
    public class Rectangle
    {
        private Color _color = new Color(1, 1, 1, 1);
        private Vector _bottomLeft;
        private Vector _topRight;

        public Color Color
        {
            get { return _color; }
            set { _color = value; }
        }

        public Rectangle(Vector bottomLeft, Vector topRight)
        {
            _bottomLeft = bottomLeft;
            _topRight = topRight;
        }

        public void Render()
        {
            Gl.glColor3f(_color.Red, _color.Green, _color.Blue);
            Gl.glBegin(Gl.GL_LINE_LOOP);
            {
                Gl.glVertex2d(_bottomLeft.X, _bottomLeft.Y);
                Gl.glVertex2d(_bottomLeft.X, _topRight.Y);
                Gl.glVertex2d(_topRight.X, _topRight.Y);
                Gl.glVertex2d(_topRight.X, _bottomLeft.Y);
            }
            Gl.glEnd();
        }

        public bool Intersects(Point point)
        {
            return point.X >= _bottomLeft.X && point.X <= _topRight.X && point.Y <= _topRight.Y && point.Y >= _bottomLeft.Y;
        }
    }
}
